package com.qualityin.mall.common.util.web.bean;

import com.github.pagehelper.Page;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.omg.CORBA.PUBLIC_MEMBER;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description:
 * @author:Steven
 * @date 2017/9/11 14:04
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class ResponseBean implements Serializable{
    public static final String SUCCESS = "200";
    public static final String FAIL = "201";
    private String status; // 状态 200成功
    private String message; // 信息
    private Object obj; // 对象
    private PageEntity page;
    public ResponseBean(){}
    public ResponseBean(String status, String message, Object obj) {
        this.status = status;
        this.message = message;
        this.obj = obj;
    }

    public ResponseBean(String status, String message) {
        this.status = status;
        this.message = message;
    }
    public static ResponseBean responseSuccess(Object entity) {
        return new ResponseBean(SUCCESS,null,entity);
    }
    public static ResponseBean responseSuccess(String status,String message, Object entity) {
        return new ResponseBean(status,message,entity);
    }
    public static ResponseBean responseSuccess(String message) {
        return new ResponseBean(SUCCESS,message);
    }
    public static ResponseBean responseSuccess(String message, Object entity) {
        return new ResponseBean(SUCCESS,message,entity);
    }
    public static ResponseBean responseFail(String message, Object entity) {
        return new ResponseBean(FAIL,message,entity);
    }
    public static ResponseBean responseFail(String message) {
        return new ResponseBean(FAIL,message);
    }
    public static ResponseBean responseSuccessForPage(Page entity,PageEntity pageEntity) {
        ResponseBean responseBean =  responseSuccess(SUCCESS,null,entity);
        pageEntity.setTotalResultSize(entity.getTotal());
        responseBean.setPage(pageEntity);
        return responseBean;
    }
}
